<template>
	<view style="background-color: black; width: 100vw;height: 100vh;">
		<image style="width: 100vw; height: 30vh; " :src="tempFilePathslist[0]" mode=""></image>
		<view
			style="position: fixed;bottom: 0;width: 100vw;height: 398rpx;border-radius: 12rpx 12rpx, 0px, 0px;background: rgba(255, 255, 255, 1);">
			<view @click="uplood1" class="fl-c"
				style="padding: 20rpx 0; border-bottom: 2rpx solid rgba(234, 234, 234, 1) ;">
				拍照
			</view>
			<view @click="uplood2" class="fl-c"
				style="padding: 20rpx 0; border-bottom: 2rpx solid rgba(234, 234, 234, 1) ;">
				从手机相册选择
			</view>
			<view class="fl-c" style="padding: 20rpx 0; border-bottom: 2rpx solid rgba(234, 234, 234, 1) ;">
				保存图片
			</view>
			<view style="height: 10rpx;opacity: 1;background: rgba(237, 237, 237, 1);">

			</view>
			<view class="fl-c" style="padding: 40rpx 0; border-bottom: 2rpx solid rgba(234, 234, 234, 1) ;">
				取消
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		
		data() {
			return {
					tempFilePathslist:['../../static/my/logo.jpg']
			}
		},
		methods: {
			uplood1() {
				var taht=this
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: [ 'camera'],
					success: function(res) {
						console.log(res);
						taht.tempFilePathslist=res.tempFilePaths
						// uni.showLoading({
						// 	title: '图片上传中'
						// });
						// that.uploadImage(res.tempFilePaths)
					}
				});
			},
			uplood2() {
				var taht=this
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: function(res) {
						console.log(res);
						taht.tempFilePathslist=res.tempFilePaths
						// uni.showLoading({
						// 	title: '图片上传中'
						// });
						// that.uploadImage(res.tempFilePaths)
					}
				});
			},
			uploadImage(tempFilePaths) {
							let _this = this;
							uni.uploadFile({
								url: 'xxxxxxxx', //接口地址
								header: {
									"token": uni.getStorageSync('token'),
								}, //请求token
								filePath: tempFilePaths[0],
								name: 'file',
								success: (res) => {
									let data = JSON.parse(res.data);
									let url = data.data.url;
									// 选中图片
									if (_this.fileList.indexOf(url) == -1) {
										_this.fileList.push(url);
									}
									uni.hideLoading();
									if (_this.fileList.length >= 3) {
										_this.uploadFlag = false
									} else {
										_this.uploadFlag = true
									}
			 
								}
							});
						},
					
		}
	}
</script>

<style>

</style>
